package com.leyou.auth.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.leyou.auth.config.AliOssProperties;
import com.leyou.auth.service.CallbackService;
import com.leyou.common.redis.RedisConstant;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Service
public class CallbackServiceImpl implements CallbackService {
    @Resource
    private RedisTemplate redisTemplate;
    @Resource
    private AliOssProperties aliOssProperties;

    @Override
    public void getSelfImage(Map<String, String> map) {
        redisTemplate.opsForSet().add(RedisConstant.BRAND_PIC_RESOURCES,map.get("image"));
    }

    @Override
    public String getOssImage(String filename) {
        String image = aliOssProperties.getHost().concat("/").concat(filename);
        redisTemplate.opsForSet().add(RedisConstant.BRAND_PIC_RESOURCES,image);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("filename",image);
        return JSONObject.toJSONString(jsonObject);
    }
}
